package cn.edu.cqut.mdm.container;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.edu.cqut.mdm.core.module.RemoteModuleEntity;

public class InvokableModuleContainer {
	private static InvokableModuleContainer instance = new InvokableModuleContainer();
	private Map<String, List<RemoteModuleEntity>> modules = new HashMap<String, List<RemoteModuleEntity>>();
	
	private InvokableModuleContainer(){
	}
	
	public static InvokableModuleContainer getInstance(){
		return instance;
	}
	
	public void addRemoteModuleEntity(RemoteModuleEntity module) {
		List<RemoteModuleEntity> list = modules.get(module.getUid());
		if(list == null) {
			list = new ArrayList<RemoteModuleEntity>();
			this.modules.put(module.getUid(), list);
		}
		list.add(module);
	}
	
	public List<RemoteModuleEntity> getModule(String uid) {
		return this.modules.get(uid);
	}
	public void putModule(String uid, List<RemoteModuleEntity> entities) {
		this.modules.put(uid, entities);
	}
	public Map<String, List<RemoteModuleEntity>> getAllModuleMap() {
		return this.modules;
	}
	public void putAllModuleMap(Map<String, List<RemoteModuleEntity>> moduleMap) {
		this.modules.putAll(moduleMap);
	}
	public void clear() {
		this.modules.clear();
	}
}
